# _*_ coding: utf-8 _*_
# @Time : 2024-01-26 13:55
# @Author : WF

"""
图片处理的库：
pip install pillow
导包
imoprt PIL
"""
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from PIL import Image


options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches", ["enable-automation"])  # 禁止控制提示


driver = webdriver.Chrome(options=options)
driver.maximize_window()
driver.get('https://www.baidu.com')

time.sleep(2)
ele = driver.find_element(By.ID, 'kw')
print('获取元素坐标：')
print(ele.location)
print(ele.size)

# 获取 四角的坐标
top = ele.location['y']
bottom = top + ele.size['height']
left = ele.location['x']
right = left + ele.size['width']
print(top, bottom, left, right)


# https://blog.csdn.net/qq_62789540/article/details/123755727
im = Image.new("RGB", (640, 480), 'red')
# im = Image.new("RGB", (640, 480), '#FFFFFF')

# 图像剪切
# im = im.crop((left, top, right, bottom))

# 打开图像
img2 = Image.open('ele.png')
img3 = Image.merge('RGB', [img2, im])

# 显示图像
img3.show()
img3.save('baidu2.png')

driver.quit()
